[NAE-2440] Fix PluginActionApi bean creation in Spring context#443
Conversation
Added methods to Action API for checking the availability of processes (`isProcessUp`, `isProcessDown`) and retrieving availability statuses (`getProcessAvailability`). Introduced `ProcessAvailability` and `ProcessAvailabilities` classes for streamlined handling of process states. Updated `ActionApiImpl` to integrate `IPetriNetService` for process status checks.
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 33 minutes and 55 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThis PR adds process availability query capabilities to the ActionApi. New data types ChangesProcess Availability Query API
Sequence DiagramsequenceDiagram
participant Caller
participant ActionApiImpl
participant IPetriNetService
participant PetriNet
Caller->>ActionApiImpl: getProcessAvailability(identifier)
ActionApiImpl->>IPetriNetService: getDefaultVersionByProcessIdentifier(identifier)
IPetriNetService->>PetriNet: lookup by identifier
PetriNet-->>IPetriNetService: PetriNet or null
IPetriNetService-->>ActionApiImpl: result
ActionApiImpl->>ActionApiImpl: ProcessAvailability.from(identifier, isPresent)
ActionApiImpl-->>Caller: ProcessAvailability
Caller->>ActionApiImpl: getProcessAvailability(List)
ActionApiImpl->>IPetriNetService: query each identifier
IPetriNetService-->>ActionApiImpl: multiple results
ActionApiImpl->>ActionApiImpl: stream to ProcessAvailability list
ActionApiImpl-->>Caller: ProcessAvailabilities
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@application-engine/src/main/java/com/netgrif/application/engine/actions/ActionApiImpl.java`:
- Around line 365-376: The batch methods getProcessAvailability(List<String>)
and getProcessAvailability(String...) currently stream over inputs and will NPE
on a null argument; add null checks at the start of each method to handle null
input gracefully (e.g., treat a null List or null varargs as an empty collection
and return new ProcessAvailabilities(Collections.emptyList()) or proceed with an
empty stream), and also defensively filter out any null elements before mapping
(e.g., filter(Objects::nonNull)) so mapping via this::getProcessAvailability
never receives null.
- Around line 359-362: The current getProcessAvailability method calls
petriNetService.getDefaultVersionByIdentifier and passes petriNet != null to
ProcessAvailability.from, which never yields Status.NOT_FOUND; instead detect
the missing process explicitly: call
petriNetService.getDefaultVersionByIdentifier inside a try/catch (or check for
null if the service returns null), and when the PetriNet is absent or a "not
found" exception occurs return ProcessAvailability.from(processIdentifier,
Status.NOT_FOUND); otherwise return ProcessAvailability.from(processIdentifier,
Status.UP) (or keep existing successful mapping). Update getProcessAvailability,
reference petriNetService.getDefaultVersionByIdentifier,
ProcessAvailability.from and Status.NOT_FOUND/Status.UP accordingly.
In
`@nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/actions/ProcessAvailabilities.java`:
- Line 3: In ProcessAvailabilities, make the process identifier comparison
null-safe by replacing any direct .equals calls on
processAvailability.processIdentifier() with
Objects.equals(processAvailability.processIdentifier(), targetIdentifier) (or
equivalent null-safe comparison), and add the necessary import for
java.util.Objects; update all occurrences of the equality check (the comparisons
around processAvailability.processIdentifier() in the lookup logic) to use
Objects.equals to avoid NullPointerException.
- Around line 106-107: The isAll(ProcessAvailability.Status status) helper
currently uses availabilities.stream().allMatch(...) which is vacuously true for
an empty availabilities list; update isAll to also require the collection is
non-empty (e.g. !availabilities.isEmpty() &&
availabilities.stream().allMatch(...)) so that isAllUp(), isAllDown(), and
isAllNotFound() return false when there are no process availabilities; reference
the isAll method, availabilities field, and ProcessAvailability.Status in your
change.
- Line 11: The record ProcessAvailabilities currently stores the caller-provided
mutable List reference; change its canonical constructor to defensively copy
and/or wrap the incoming list (e.g., assign List.copyOf(availabilities) or an
unmodifiable copy) so the record field is immutable and the internal state can't
be mutated by callers; update the record's constructor/body to perform the copy
and optionally validate non-null input in the ProcessAvailabilities(List
availabilities) constructor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 42712dfe-55ca-4eeb-8afe-ff842ff8075c
📒 Files selected for processing (4)
application-engine/src/main/java/com/netgrif/application/engine/actions/ActionApiImpl.javanae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/actions/ActionApi.javanae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/actions/ProcessAvailabilities.javanae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/actions/ProcessAvailability.java
…dling Added null checks for `processIdentifiers` in `getProcessAvailability` overloads to prevent potential null pointer exceptions. Refactored `ProcessAvailabilities` to enforce immutability and improve consistency when handling availability lists.
|
@coderabbitai please make review once more, I already made changes according to your commnts. |
|
✅ Previously raised issues — all resolved
🔍 Remaining minor observations1. Indentation inconsistency in
|
Description
Fixes NAE-2440
Dependencies
No new dependencies were introduced
Third party dependencies
Blocking Pull requests
There are no dependencies on other PR
How Has Been This Tested?
This was tested manually and with unit tests.
Test Configuration
Checklist:
Summary by CodeRabbit
New Features